package javaTec.ThreadPrograming;

import java.util.TreeMap;

public class Run {
	

	public static void main(String[] args) throws InterruptedException {
		final long start = System.currentTimeMillis();
		Count count = new Count();
		runTest(count);
		System.out.println(count);
		System.out.println("duration = " + (System.currentTimeMillis() - start));
	}

	private static void runTest(final Count count) throws InterruptedException {
		Thread[] threads = new Thread[4];
		for (int i = 0; i < threads.length; i++) {
			threads[i] = new Thread(new Runnable() {

				@Override
				public void run() {
					for (int i = 0; i < 500L * 1000L * 1000L; i++) {
						count.incrByLongAdder();
					}

				}
			});
		}
		for (Thread t : threads) {
			t.start();
		}
		for (Thread t : threads) {
			t.join();
		}
	}

}
